package com.workcenter.controls;

import java.util.List;

import com.workcenter.app.R;
import com.workcenter.entity.model.ERepairsInfo;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class AdpLV_RepairsInfo extends BaseAdapter
{
   private List<ERepairsInfo> list;
   private Context mContext;
   private LayoutInflater mInflater;

   public AdpLV_RepairsInfo()
   {

   }

   public AdpLV_RepairsInfo(List<ERepairsInfo> _list, Context _context)
   {
	  list = _list;
	  mContext = _context;
	  mInflater = LayoutInflater.from(_context);
   }

   @Override
   public int getCount()
   {
	  return list.size();
   }

   @Override
   public Object getItem(int position)
   {
	  return list.get(position);
   }

   @Override
   public long getItemId(int position)
   {
	  return 0;
   }

   @Override
   public View getView(int position, View convertView, ViewGroup parent)
   {
	  try
	  {
		 convertView = mInflater.inflate(R.layout.main_repairlist_item, null);
		 TextView txtCustomer = (TextView) convertView.findViewById(R.id.txtCustomer_main_item);
		 TextView txtInstrument = (TextView) convertView.findViewById(R.id.txtInstrument_main_item);
		 TextView txtDiagnosis = (TextView) convertView.findViewById(R.id.txtDiagnosis_main_item);
		 TextView txtProgress = (TextView) convertView.findViewById(R.id.txtProgress_main_item);
		
		 txtCustomer.setText(list.get(position).getCustomerName());
		 txtInstrument.setText(list.get(position).getInstrument());
		 txtDiagnosis.setText(list.get(position).getDiagnosis());
		 txtProgress.setText(list.get(position).getProgress());

		 return convertView;
	  }
	  catch (Exception e)
	  {

	  }
	  return new View(mContext);

   }
}
